package pkg

import (
	"encoding/json"
	"fmt"
	"github.com/Baidu-AIP/golang-sdk/aip/censor"
	"user-srv/basic/inits"
)

type conclusionType struct {
	ConclusionType uint64 `json:"conclusionType"`
}

func Baid(message string) bool {
	conf := inits.Config.Bai
	client := censor.NewClient(conf.Ak, conf.Sk)
	res := client.TextCensor(message)
	fmt.Println(res)

	var con conclusionType
	_ = json.Unmarshal([]byte(res), &con)
	if con.ConclusionType == 1 {
		return true
	}
	return false
}
